import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import store from '@/store'
import less from '@/less/index.less'
import axios from 'axios'
import directive from '@/directive'
// import Cookies from 'js-cookie'
import Pagination from '@/utils/Pagination'
import Treeselect from '@riophae/vue-treeselect'
//弹幕
import { vueBaberrage } from 'vue-baberrage'
// Vue.use(vueBaberrage)
Vue.component('vueBaberrage', vueBaberrage)
//视频播放
import { videoPlayer } from 'vue-video-player'
import 'videojs-contrib-hls'
import 'video.js/dist/video-js.css'

// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar'
import { parseTime } from '@/utils/common'
import { download } from '@/api/axios'

// 引入rem适配
import '@/assets/js/rem'
// 引入自定义样式
import '@/assets/styles/reset.css' //重置样式
import '@/assets/styles/base.css' //通用样式
import '@/assets/styles/main.css'
import 'font-awesome/css/font-awesome.min.css'
import 'element-ui/lib/theme-chalk/index.css'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import config from '@/config'
import cache from "@/plugins/cache";

Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(directive)
Vue.prototype.$axios = axios
// Vue.prototype.$cookie = Cookies
//全局方法挂载
Vue.prototype.parseTime = parseTime
Vue.prototype.download = download
//全局组件挂载
Vue.component('Pagination', Pagination)
Vue.component('TreeSelect', Treeselect)
Vue.component('RightToolbar', RightToolbar)
Vue.component('videoPlayer', videoPlayer)
new Vue({
    router,
    store,
    less,
    render: (h) => h(App)
}).$mount('#app')

router.beforeEach((to, from, next) => {
    // if (!Cookies.get('token') && to.name != 'login') {
    if (!cache.session.getJSON('token') && to.name != 'login') {
        next({
            name: 'login',
            query: to.query
        })
    } /* else {
        if (to.name != 'login') {
            store.dispatch('GetInfo')
        }
        next()
    }*/
    next()
})
